<template>
  <div
    class="abstract-item "
    @click="$router.push(item.path)">
    <i v-if="item.frontmatter.sticky" class="iconfont reco-sticky"></i>
    <div class="cover-wrap img2">
      <div class="cover" :style="{ ...bgImageStyle }" >

      </div>
    </div>
    <div class="abstract-content-wrap">
      <div class="title">
        <i v-if="item.frontmatter.keys" class="iconfont reco-lock"></i>
        <router-link :to="item.path">{{item.title}}</router-link>
      </div>
      <div class="abstract" v-html="item.excerpt"></div>
      <PageInfo :pageInfo="item" :currentTag="currentTag"  >
      </PageInfo>
    </div>
  </div>
</template>

<script>
import PageInfo from './PageInfos'
export default {
  components: { PageInfo },
  props: ['item', 'currentPage', 'currentTag'],
  computed: {
    bgImageStyle () {
      //https://cdn.jsdelivr.net/gh/Mu-Yan/Mu-Yan.github.io/13.jpg
      let random_bg=Math.floor(Math.random()*19+1)
      const initBgImageStyle = {
        textAlign: 'center',
        overflow: 'hidden',
        background: 'url(/img/'+this.item.frontmatter.imgpath+'.jpg) center/cover no-repeat'
      }
      const {
        bgImageStyle
      } = this.$frontmatter

      return bgImageStyle ? { ...initBgImageStyle, ...bgImageStyle } : initBgImageStyle
    }
  }
}
</script>

<style lang="stylus" scoped>


  /*效果二：放大 修改scale(放大的值)*/
  .img2 {
    transition: All 0.4s ease-in-out;
    -webkit-transition: All 0.4s ease-in-out;
    -moz-transition: All 0.4s ease-in-out;
    -o-transition: All 0.4s ease-in-out;
    -webkit-transform: scale(0.9);
  }

  .img2:hover {
    transform: scale(1.2);
    -webkit-transform: scale(1);
    -moz-transform: scale(1.2);
    -o-transform: scale(1.2);
    -ms-transform: scale(1.2);
  }

@require '../styles/mode.styl'
.abstract
  margin-left: 10px;
.abstract-content-wrap
  width: 50%;
  margin: 0 1rem;
  flex: 1;
  flex-direction: column;
  justify-content: center;
  display: flex;
  transition: all .3s;
.cover-wrap .cover
  width: 100%;
  height: 100%;
  transition: transform .5s;
  transform: scale(1.1);
.cover-wrap
  width: 50%;
  flex: 1;
  float: left;
  transition: 1s ease-out;
  border-radius: .5rem;
  overflow: hidden;
  height: 200px;
  position: relative;
.abstract-item
  position relative
  margin: 0 auto 20px;
  padding: 16px 20px;
  width 100%
  overflow: hidden;
  border-radius: $borderRadius
  box-shadow: var(--box-shadow);
  box-sizing: border-box;
  transition all .3s
  background-color var(--background-color)
  cursor: pointer;
  > * {
    pointer-events: auto;
  }
  .reco-sticky
    position absolute
    top 0
    left 0
    display inline-block
    color $accentColor
    font-size 2.4rem
  &:hover
    box-shadow: var(--box-shadow-hover)
  .title
    position: relative;
    margin-left: 10px;
    font-size: 1.28rem;
    line-height: 46px;
    display: inline-block;
    a
      color: var(--text-color);
    .reco-lock
      font-size 1.28rem
      color $accentColor
    &:after
      content: "";
      position: absolute;
      width: 100%;
      height: 2px;
      bottom: 0;
      left: 0;
      background-color: $accentColor;
      visibility: hidden;
      -webkit-transform: scaleX(0);
      transform: scaleX(0);
      transition: .3s ease-in-out;
    &:hover a
      color $accentColor
    &:hover:after
      visibility visible
      -webkit-transform: scaleX(1);
      transform: scaleX(1);
  .tags
    .tag-item
      &.active
        color $accentColor
      &:hover
        color $accentColor
@media (max-width: $MQMobile)
  .tags
    display block
    margin-top 1rem;
    margin-left: 0!important;
</style>
